FROM golang:1.16 as build
RUN export GO111MODULE=on
RUN export GOPROXY=https://proxy.golang.org,direct
WORKDIR /home/cncfstudy/httpserver/
COPY main.go .
RUN go mod init httpserver
RUN CGO_ENABLED=0 GOOS=linux  go build  -o httpserver  .

FROM alpine:latest as run
RUN apk --no-cache add ca-certificates
ENV MY_SERVICE_PORT=80
WORKDIR /root/
COPY  --from=build /home/cncfstudy/httpserver/httpserver  .
RUN chmod +x httpserver
EXPOSE 80
CMD ["./httpserver"]
LABEL applabel ="httpserver"